package com.itcast.demo_one.kotlin

fun main(){
    // 1.遍历1-10 用in
    for(i in 1..10){
        print(i)
    }
    println()
    println("----------------")

    // 2.遍历1-10 用until
    for(i in 1 until 10){
        print(i)
    }
    println()
    println("----------------")

    // 3.遍历1-10 用downTo,降序排列
    for(i in 10 downTo 1){
        print(i)
    }
    println()
    println("----------------")

    // 4.遍历1-10 用step
    for(i in 1..10 step 2){
        print(i)
    }
    println()
    println("----------------")

    val myList = listOf("张三", "李四", "王五", "赵六", "孙七")
    for(i in myList){
        print(i)
    }
    println()
    println("----------------")
    myList.forEach{print(it)}
}
